home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1993 April: Penguin on DISC / ADC Developer CD (1993-04) (''Penguin On DISC'')_iso / Dev.CD Apr 93.iso / Utilities / MPW Interfaces 7.1 Beta / CIncludes / Components.h < prev    next >
Encoding:
C/C++ Source or Header  |  1992-08-28  |  8.2 KB  |  273 lines  |  [TEXT/MPS ]

  1. /************************************************************
  2.  
  3. Created: Wednesday, August 14, 1991 at 12:09 PM
  4.  Components.h
  5.  C Interface to the Macintosh Libraries
  6.  
  7.  
  8.  Copyright Apple Computer, Inc. 1990 - 1991
  9.  All rights reserved
  10.  
  11. ************************************************************/
  12.  
  13.  
  14. #ifndef __COMPONENTS__
  15. #define __COMPONENTS__
  16.  
  17. #ifndef __TYPES__
  18. #include <Types.h>
  19. #endif
  20.  
  21.  
  22. #define    kAnyComponentType            0
  23. #define    kAnyComponentSubType        0
  24. #define    kAnyComponentManufacturer    0
  25. #define    kAnyComponentFlagsMask        0
  26.  
  27. enum {
  28.     cmpWantsRegisterMessage = 1L<<31
  29. };
  30.  
  31. struct ComponentDescription {
  32.  OSType componentType;                    /* A unique 4-byte code indentifying the command set */
  33.  OSType componentSubType;                /* Particular flavor of this instance */
  34.  OSType componentManufacturer;            /* Vendor indentification */
  35.  unsigned long componentFlags;            /* 8 each for Component,Type,SubType,Manuf/revision */
  36.  unsigned long componentFlagsMask;        /* Mask for specifying which flags to consider in search, zero during registration */
  37. };
  38.  
  39. typedef struct ComponentDescription ComponentDescription;
  40.  
  41. struct ResourceSpec {
  42.  OSType resType;                        /* 4-byte code  */
  43.  short resId;                            /*    */
  44. };
  45.  
  46. typedef struct ResourceSpec ResourceSpec;
  47.  
  48. struct ComponentResource {
  49.  ComponentDescription cd;                /* Registration parameters */
  50.  ResourceSpec component;                /* resource where Component code is found */
  51.  ResourceSpec componentName;            /* name string resource */
  52.  ResourceSpec componentInfo;            /* info string resource */
  53.  ResourceSpec componentIcon;            /* icon resource */
  54. };
  55.  
  56. typedef struct ComponentResource ComponentResource;
  57. typedef ComponentResource *ComponentResourcePtr, **ComponentResourceHandle;
  58.  
  59. /* Structure received by Component:  */
  60. struct ComponentParameters {
  61.  unsigned char flags;                    /* call modifiers: sync/async, deferred, immed, etc */
  62.  unsigned char paramSize;                /* size in bytes of actual parameters passed to this call */
  63.  short what;                            /* routine selector, negative for Component management calls */
  64.  long params[1];                        /* actual parameters for the indicated routine */
  65. };
  66.  
  67. typedef struct ComponentParameters ComponentParameters;
  68.  
  69.  
  70. struct ComponentRecord {
  71.  long data[1];
  72. };
  73.  
  74. typedef struct ComponentRecord ComponentRecord;
  75. typedef ComponentRecord *Component;
  76.  
  77. struct ComponentInstanceRecord {
  78.  long data[1];
  79. };
  80.  
  81. typedef struct ComponentInstanceRecord ComponentInstanceRecord;
  82. typedef ComponentInstanceRecord *ComponentInstance;
  83.  
  84.  
  85.  
  86. typedef long ComponentResult;
  87.  
  88. typedef pascal ComponentResult (*ComponentRoutine)
  89.   (ComponentParameters *tp, Handle componentStorage );
  90.  
  91. typedef pascal ComponentResult (*ComponentFunction)();
  92.  
  93.  
  94.  
  95.  
  96.  
  97. #define ComponentCallNow( callNumber, paramSize ) \
  98.   {0x2F3C,paramSize,callNumber,0x7000,0xA82A}
  99.  
  100. #ifdef __cplusplus
  101. extern "C" {
  102. #endif
  103.  
  104. /* 
  105.  *******************************************************
  106.  *                                                     *
  107.  *              APPLICATION LEVEL CALLS                *
  108.  *                                                     *
  109.  *******************************************************
  110.  * Component Database Add, Delete, and Query Routines 
  111.  *******************************************************
  112. */
  113.  
  114. pascal Component RegisterComponent(ComponentDescription *cd,ComponentRoutine componentEntryPoint,
  115.  short global,Handle componentName,Handle componentInfo,Handle componentIcon)
  116.  = {0x7001,0xA82A}; 
  117. pascal Component RegisterComponentResource(ComponentResourceHandle tr,short global)
  118.  = {0x7012,0xA82A}; 
  119. pascal OSErr UnregisterComponent(Component aComponent)
  120.  = {0x7002,0xA82A}; 
  121.  
  122. pascal Component FindNextComponent(Component aComponent,ComponentDescription *looking)
  123.  = {0x7004,0xA82A}; 
  124. pascal long CountComponents(ComponentDescription *looking)
  125.  = {0x7003,0xA82A}; 
  126.  
  127. pascal OSErr GetComponentInfo(Component aComponent,ComponentDescription *cd,
  128.  Handle componentName,Handle componentInfo,Handle componentIcon)
  129.  = {0x7005,0xA82A}; 
  130. pascal long GetComponentListModSeed(void)
  131.  = {0x7006,0xA82A}; 
  132.  
  133.  
  134. /* 
  135.  *******************************************************
  136.  * Component Instance Allocation and dispatch routines 
  137.  *******************************************************
  138. */
  139.  
  140. pascal ComponentInstance OpenComponent(Component aComponent)
  141.  = {0x7007,0xA82A}; 
  142. pascal OSErr CloseComponent(ComponentInstance aComponentInstance)
  143.  = {0x7008,0xA82A}; 
  144.  
  145. pascal OSErr GetComponentInstanceError(ComponentInstance aComponentInstance)
  146.  = {0x700A,0xA82A}; 
  147.  
  148. /*  direct calls to the Components  */
  149. pascal long ComponentFunctionImplemented(ComponentInstance ci,short ftnNumber)
  150.  = {0x2F3C,0x2,0xFFFD,0x7000,0xA82A}; 
  151. pascal long GetComponentVersion(ComponentInstance ci)
  152.  = {0x2F3C,0x0,0xFFFC,0x7000,0xA82A}; 
  153. #ifdef __cplusplus
  154. }
  155. #endif
  156.  
  157.  
  158.  
  159. /*****************************************************
  160. *                                                    *
  161. *               CALLS MADE BY Components             *
  162. *                                                    *
  163. ******************************************************
  164. ******************************************************
  165. * Required Component routines
  166. *******************************************************/
  167.  
  168.  
  169. #define kComponentOpenSelect -1            /* ComponentInstance for this open */
  170. #define kComponentCloseSelect -2        /* ComponentInstance for this close */
  171. #define kComponentCanDoSelect -3        /* selector # being queried */
  172. #define kComponentVersionSelect -4        /* no params */
  173. #define kComponentRegisterSelect -5        /* no params */
  174. #define kComponentTargetSelect -6        /* ComponentInstance for top of call chain */
  175.  
  176. #ifdef __cplusplus
  177. extern "C" {
  178. #endif
  179.  
  180. /* 
  181.  *******************************************************
  182.  * Component Management routines
  183.  *******************************************************
  184. */
  185.  
  186. pascal void SetComponentInstanceError(ComponentInstance aComponentInstance,
  187.  OSErr theError)
  188.  = {0x700B,0xA82A}; 
  189.  
  190. pascal long GetComponentRefcon(Component aComponent)
  191.  = {0x7010,0xA82A}; 
  192. pascal void SetComponentRefcon(Component aComponent,long theRefcon)
  193.  = {0x7011,0xA82A}; 
  194.  
  195. pascal short OpenComponentResFile(Component aComponent)
  196.  = {0x7015,0xA82A}; 
  197. pascal OSErr CloseComponentResFile(short refnum)
  198.  = {0x7018,0xA82A}; 
  199.  
  200.  
  201. /* 
  202.  *******************************************************
  203.  * Component Instance Management routines
  204.  *******************************************************
  205. */
  206.  
  207. pascal Handle GetComponentInstanceStorage(ComponentInstance aComponentInstance)
  208.  = {0x700C,0xA82A}; 
  209. pascal void SetComponentInstanceStorage(ComponentInstance aComponentInstance,
  210.  Handle theStorage)
  211.  = {0x700D,0xA82A}; 
  212.  
  213. pascal long GetComponentInstanceA5(ComponentInstance aComponentInstance)
  214.  = {0x700E,0xA82A}; 
  215. pascal void SetComponentInstanceA5(ComponentInstance aComponentInstance,
  216.  long theA5)
  217.  = {0x700F,0xA82A}; 
  218.  
  219. pascal long CountComponentInstances(Component aComponent)
  220.  = {0x7013,0xA82A}; 
  221.  
  222. /*  useful helper routines for convenient method dispatching  */
  223. pascal long CallComponentFunction(ComponentParameters *params,ComponentFunction func)
  224.  = {0x70FF,0xA82A}; 
  225. pascal long CallComponentFunctionWithStorage(Handle storage,ComponentParameters *params,
  226.  ComponentFunction func)
  227.  = {0x70FF,0xA82A}; 
  228. pascal long DelegateComponentCall(ComponentParameters *originalParams,ComponentInstance ci)
  229.  = {0x7024,0xA82A}; 
  230. #ifdef __cplusplus
  231. }
  232. #endif
  233. enum {
  234.  
  235.  
  236. /* Set Default Component flags */
  237.  defaultComponentIdentical = 0,
  238.  defaultComponentAnyFlags = 1,
  239.  defaultComponentAnyManufacturer = 2,
  240.  defaultComponentAnySubType = 4
  241.  
  242. #define defaultComponentAnyFlagsAnyManufacturer defaultComponentAnyFlags+defaultComponentAnyManufacturer
  243. #define defaultComponentAnyFlagsAnyManufacturerAnySubType defaultComponentAnyFlags+defaultComponentAnyManufacturer+defaultComponentAnySubType
  244. };
  245.  
  246. #ifdef __cplusplus
  247. extern "C" {
  248. #endif
  249. pascal OSErr SetDefaultComponent(Component aComponent,short flags)
  250.  = {0x701E,0xA82A}; 
  251. pascal ComponentInstance OpenDefaultComponent( OSType componentType, OSType componentSubType )
  252.  = {0x7021,0xA82A}; 
  253. pascal Component CaptureComponent(Component capturedComponent,Component capturingComponent)
  254.  = {0x701C,0xA82A}; 
  255. pascal OSErr UncaptureComponent(Component aComponent)
  256.  = {0x701D,0xA82A}; 
  257. #ifdef __cplusplus
  258. }
  259. #endif
  260.  
  261. typedef enum {                    /* errors from component manager & components  */
  262.     invalidComponentID = -3000,
  263.     validInstancesExist = -3001,
  264.     componentNotCaptured = -3002,
  265.     componentDontRegister = -3003
  266.     };
  267.  
  268. #define badComponentInstance    0x80008001
  269. #define badComponentSelector    0x80008002
  270.  
  271.  
  272. #endif
  273.